﻿using LuaFramework;
using DG.Tweening;
using System.IO;
using UnityEngine;

public class AppFacade : Facade
{
    private static AppFacade _instance;

    public AppFacade() : base()
    {
    }

    public static AppFacade Instance
    {
        get{
            if (_instance == null) {
                _instance = new AppFacade();
            }
            return _instance;
        }
    }

    public static bool isShuttingDown;

    /// <summary>
    /// 启动框架
    /// </summary>
    ///     
    /// 

    public void StartUp() {
        isShuttingDown = false;

        AppFacade.Instance.AddManager<LuaManager>(ManagerName.Lua);
        AppFacade.Instance.AddManager<NetworkManager>(ManagerName.Network);
        AppFacade.Instance.AddManager<SoundManager>(ManagerName.Sound);
        AppFacade.Instance.AddManager<TimerManager>(ManagerName.Timer);
        AppFacade.Instance.AddManager<ResourceManager>(ManagerName.Resource);
        AppFacade.Instance.AddManager<GameManager>(ManagerName.Game);      
        AppFacade.Instance.AddManager<ThreadManager>(ManagerName.Thread);
        AppFacade.Instance.AddManager<EventManager>(ManagerName.Event);
        AppFacade.Instance.AddManager<RecorderManager>(ManagerName.Record);
        AppFacade.Instance.AddManager<DatabaseManager>(ManagerName.Database);

#if UNITY_EDITOR

        LoadManager.loadFromEditor = true;
        VersionInfo.onlinePatchVer = int.MaxValue;
#endif
        LoadManager.useDownloadData = true;

        gameManager.ChangeState("ProcInit");
    }

    public static GameManager gameManager
    {
        get { return Instance.GetManager<GameManager>(ManagerName.Game); }
    }

    public static LuaManager luaManager
    {
        get { return Instance.GetManager<LuaManager>(ManagerName.Lua); }
    }

    public static ResourceManager resourceManager
    {
        get { return Instance.GetManager<ResourceManager>(ManagerName.Resource); }
    }

    public static SoundManager soundManager
    {
        get { return Instance.GetManager<SoundManager>(ManagerName.Sound); }
    }

    public static NetworkManager networkManager
    {
        get { return Instance.GetManager<NetworkManager>(ManagerName.Network); }
    }

    public static ThreadManager threadManager
    {
        get { return Instance.GetManager<ThreadManager>(ManagerName.Thread); }
    }

    public static EventManager eventManager
    {
        get { return Instance.GetManager<EventManager>(ManagerName.Event); }
    }

    public static TimerManager timerManager
    {
        get { return Instance.GetManager<TimerManager>(ManagerName.Timer); }
    }

    public static RecorderManager recordManager
    {
        get { return Instance.GetManager<RecorderManager>(ManagerName.Record); }
    }


    public static DatabaseManager databaseManager
    {
        get { return Instance.GetManager<DatabaseManager>(ManagerName.Database); }
    }
}

